﻿/* EntitiesToDTOs. Copyright (c) 2011. Fabian Fernandez.
 * http://entitiestodtos.codeplex.com
 * Licensed by Common Development and Distribution License (CDDL).
 * http://entitiestodtos.codeplex.com/license
 * Fabian Fernandez. 
 * http://www.linkedin.com/in/fabianfernandezb/en
 * */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using EntitiesToDTOs.Properties;

namespace EntitiesToDTOs.Helpers
{
    /// <summary>
    /// Helps in the tasks relative to the Assembly.
    /// </summary>
    internal class AssemblyHelper
    {
        /// <summary>
        /// Assembly that contains the code that is currently executing.
        /// </summary>
        private static Assembly ExecutingAssembly
        {
            get
            {
                if (_executingAssembly == null)
                {
                    _executingAssembly = Assembly.GetExecutingAssembly();
                }

                return _executingAssembly;
            }
        }
        private static Assembly _executingAssembly = null;

        /// <summary>
        /// AssemblyName of the Assembly that contains the code that is currently executing.
        /// </summary>
        private static AssemblyName ExecutingAssemblyName
        {
            get
            {
                if (_executingAssemblyName == null)
                {
                    _executingAssemblyName = AssemblyHelper.ExecutingAssembly.GetName();
                }

                return _executingAssemblyName;
            }
        }
        private static AssemblyName _executingAssemblyName = null;

        /// <summary>
        /// Executing Assembly Version in the form of Major.Minor.
        /// </summary>
        public static string Version
        {
            get
            {
                if (_version == null)
                {
                    _version = (
                        AssemblyHelper.ExecutingAssemblyName.Version.Major.ToString() +
                        Resources.Dot +
                        AssemblyHelper.ExecutingAssemblyName.Version.Minor.ToString());
                }

                return _version;
            }
        }
        private static string _version = null;
    }
}